<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form lay-filter="systemLoginInfoForm" class="layui-form model-form" id="systemLoginInfoForm">
                <input id="id" name="id" type="hidden"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">app_id</label>
                    <div class="layui-input-block">
                        <input name="appId" placeholder="请输入app_id" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">agent_id</label>
                    <div class="layui-input-block">
                        <input name="agentId" placeholder="请输入agent_id" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">client_id</label>
                    <div class="layui-input-block">
                        <input name="clientId" placeholder="请输入client_id" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">client_secret</label>
                    <div class="layui-input-block">
                        <input name="clientSecret" placeholder="请输入client_secret" type="text"
                               class="layui-input" lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">corp_id</label>
                    <div class="layui-input-block">
                        <input name="corpId" placeholder="请输入corp_id" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">公司名称</label>
                    <div class="layui-input-block">
                        <input name="companyName" placeholder="请输入公司名称" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                    <button class="layui-btn" lay-filter="systemLoginInfoFormSubmit" lay-submit>保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
<style>
    #systemLoginInfoForm .layui-form-label{
        width: 160px;
        padding-left: 0;
    }
    #systemLoginInfoForm .layui-input-block{
        margin-left: 185px;
    }
</style>
<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        list();

        //初始化表单
        function list() {
            admin.req('enterprise/system/admin/systemDingTalkInfo/list', {}, function (res) {
                form.val("systemLoginInfoForm", res.data[0]);
                form.render();
            }, 'GET');
        }

        // 表单提交事件
        form.on('submit(systemLoginInfoFormSubmit)', function (d) {
            if ($("#id").val() != "") {
                admin.req('enterprise/system/admin/systemDingTalkInfo/addOrUpdate', d.field, function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                    list();
                }, 'POST');
            } else {
                admin.req('enterprise/system/admin/systemDingTalkInfo/addOrUpdate', d.field, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                    list();
                }, 'POST');
            }
            return false;
        });


    });
</script>